package com.alibaba.citrus.cr.common.config;

import com.alibaba.cz.base.tool.log.Log;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author: qiaojiange
 * @create: 2021/09/23
 * @Description 线程池使用 demo,仅供参考，注释的代码打开之后就可以正常使用。
 */
@Component
@EnableScheduling
public class ThreadPoolUseDemo {
    private static Log log = Log.getLogger(ThreadPoolUseDemo.class);

    @Resource(name = "forecastSaleTaskExecutor")
    private ThreadPoolTaskExecutor forecastSaleTaskExecutor;

//    @Scheduled(cron = "* * * * * MON-FRI")
//    public void test01(){
//        System.out.println("---test01 "+ new Date(System.currentTimeMillis()));
//        forecastSaleTaskExecutor.execute(()->{
//            try {
//                Thread.sleep(500);
//                System.out.println("---thread: "+Thread.currentThread().getName());
//            } catch (InterruptedException e) {
//                e.printStackTrace();
//            }
//        });
//    }

}
